<template>
	<view class="collection">
		<view class="empty" v-if="!collectionList.length">
			<empty text="你可以把心仪的车放在这里,方便你查看~">
				<u-button type="primary" text="去看看~" size="small" @click="toLook"></u-button>
			</empty>
		</view>
		<good-list :list="collectionList" v-else></good-list>
		<view class="recommend">
			<view class="title">
				为你推荐
			</view>
			<flow :list="recommendList"></flow>
		</view>
	</view>
</template>

<script>
	import {get_recommend,get_collect} from '@/api/contents/collection/collection.js'
	import goodList from '@/components/common/goodList/goodList.vue'
	import empty from '@/components/home/empty/empty.vue'
	import flow from '@/components/common/flow/flow.vue'
	export default {
		components: {
			empty,
			flow,
			goodList
		},
		data() {
			return {
				recommendList:[],//推荐列表
				collectionList:[],//收藏列表
			};
		},
		methods:{
			// 获取推荐列表
			getCarList(){
				get_recommend().then(res=>{
					if(res.code==1){
						this.recommendList=res.data;
					}
				})
			},
			getCollection(){
				get_collect().then(res=>{
					if(res.code==1){
						this.collectionList=res.data;
					}
				})
			},
			toLook(){
				uni.switchTab({
					url:'../buyCar/buyCar'
				})
			}
		},
		onLoad() {
			this.getCarList();
			this.getCollection();
		}
	}
</script>

<style lang="scss" scoped>
	.collection {
		background: #F5F7FA;

		.empty {
			background: #fff;
			padding: 40upx 0;
		}

		.recommend {
			padding: 0 20upx;

			.title {
				height: 80upx;
				line-height: 80upx;
				font-size: 32upx;
				color: #303741;
				letter-spacing: 0;
				font-weight: 700;
			}
		}

	}
</style>
